/*
 * @Description:批次管理操作
 * @Author: Rfan
 * @Date: 2022-04-28 13:47:59
 * @LastEditTime: 2022-05-10 16:21:46
 */

import { useMemo, useState } from 'react';
import { Button, Divider, Space } from 'antd';
import cs from 'classnames';
import CreateBatchDialog from './dialogs/CreateBatch';
import { useReceiveTypeContext } from '../contexts/ReceiveWaysContext';
import { useBatchManageContext } from '../contexts/BatchManageContext';
import { EnumReceiveWays } from '@/view/accession/BatchManage/dictionaries';

const PageOperate = (props: any) => {
  const { classname } = props;

  const { type: businessType, title } = useReceiveTypeContext();
  const { selectItems, deleteBatchFunc } = useBatchManageContext();
  // 导入excel弹窗显示标志

  const [createBatchVisible, setCreateBatchVisible] = useState(false);

  return (
    <div className={cs('filter-container', 'page-operate', classname)}>
      <p>{title}</p>
      <Space size="small">
        {businessType !== EnumReceiveWays.Online && (
          <Button
            onClick={() => {
              setCreateBatchVisible(true);
            }}
          >
            新建接收任务
          </Button>
        )}
        <Button>入库</Button>
        <Button>从库中撤回</Button>
        <Button>打回</Button>
        <Button>下载</Button>
        <Button
          onClick={() => {
            deleteBatchFunc(selectItems, '是否删除选中的批次');
          }}
        >
          删除
        </Button>
        <Button>规范性检测</Button>
        <Divider type="vertical" />
        <Button>筛选检索</Button>
      </Space>
      {useMemo(
        () => (
          <CreateBatchDialog
            visible={createBatchVisible}
            onClose={() => {
              setCreateBatchVisible(false);
            }}
          />
        ),
        [createBatchVisible]
      )}
    </div>
  );
};

export default PageOperate;
